package com.hctrl.mybatis.interceptor.handler;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;

import java.time.LocalDateTime;

/**
 * @author hanchao
 * @version 1.0
 * @date 2022/5/28 12:42
 */
public class LocalDateTimeTypeHandler implements TypeHandler<LocalDateTime> {

    @Override
    public Boolean isSupport(Class<?> type) {
        return type.equals(LocalDateTime.class);
    }

    @Override
    public String handler(LocalDateTime localDateTime) {
        String format = DateUtil.format(localDateTime, DatePattern.NORM_DATETIME_PATTERN);
        return new StringBuilder().append("'").append(format).append("'").toString();
    }

}
